package com.lazydong.gui_gateway;

import com.lazydong.gui_gateway.gui.JFrameApp;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.web.bind.annotation.RestController;

import java.io.FileNotFoundException;

@RestController
@SpringBootApplication
public class GatewayApplication {
    public static Boolean runFlag = false;
    public static ConfigurableApplicationContext applicationContext = null;


    public static void main(String[] args) throws FileNotFoundException {
//        RoutePropertyEnvironment.port.set(44944);
        startGateway(args);
//        JFrameApp.guiMain(args);
    }

    public static void startGateway(String[] args) {
        if (GatewayApplication.runFlag) {
            return;
        }
        applicationContext = SpringApplication.run(GatewayApplication.class, args);
        GatewayApplication.runFlag = true;
        System.out.println("路由服务已启动");
    }


    public static void stopGateway() {
        if (!GatewayApplication.runFlag) {
            return;
        }
        applicationContext.close();
        GatewayApplication.runFlag = false;
        System.out.println("路由服务已停止");
    }

}
